home *** CD-ROM | disk | FTP | other *** search
- 100 sys 700:.opt oo:*=$c000
- 105 ; *************************
- 110 ; * *
- 115 ; * ml sound generator *
- 120 ; * happy sounding bach *
- 125 ; * robert alonso *
- 130 ; * *
- 135 ; *************************
- 140 ;
- 145 ; equates
- 150 ;
- 155 sigvol = $d418
- 160 atdcy1 = $d405
- 165 surel1 = $d406
- 170 vcreg1 = $d404
- 175 frelo1 = $d400
- 180 frehi1 = $d401
- 185 ;
- 190 ; initialization
- 195 ;
- 200 lda #$0f ;set the volume to 15.
- 205 sta sigvol ;like poke 54296,15.
- 210 ;
- 215 lda #$09 ;set attack/decay to 9.
- 220 sta atdcy1 ;like poke 54277,9.
- 225 ;
- 230 lda #$11 ;sustain/release to 17.
- 235 sta surel1 ;like poke 54278,17.
- 240 ;
- 245 lda #$11 ;select triangle wave.
- 250 sta vcreg1 ;like poke 54276,17.
- 255 ;
- 260 ldx #$00 ;zero out the offset.
- 265 ;
- 270 ; main loop, gets and plays notes.
- 275 ;
- 280 loop = *
- 285 lda notes,x ;get the hi value and
- 290 sta frehi1 ;store it in register.
- 295 inx ;increase offset.
- 300 ;
- 305 lda notes,x ;get lo value and store
- 310 sta frelo1 ;it in register.
- 315 inx ;increase offset again.
- 320 ;
- 325 lda notes,x ;get the duration value
- 330 sta asave ;and store it in asave.
- 335 inx ;increase the offset.
- 340 ;
- 345 stx xsave ;save the offset value
- 350 jsr delay ;and (NULL) to the delay.
- 355 ;
- 360 lda #$11 ;reset triangle wave.
- 365 sta vcreg1 ;delay turns it off.
- 370 ;
- 375 ldx xsave ;get the offset value.
- 380 cpx #$60 ;"is it 96?
- 385 bne loop ;no, [167] loop again.
- 390 jmp [128] ;yes, [167] [203] [164] [128].
- 395 ;
- 400 ; delay loop used [129] durati[145].
- 405 ;
- 410 delay [178] [172]
- 415 ldy #$00 ;zero the .y offset
- 420 ;
- 425 set ldx #$00;[175] the .x offset.
- 430 play inx ;increase the .x
- 435 cpx #$ff ;"does .x=255?
- 440 bne play ;no, then (NULL) to play.
- 445 ;
- 450 iny ;yes, increase .y
- 455 cpy #$4b ;"does .y=75?
- 460 bne set ;no, [167] [203] [164] set.
- 465 ;
- 470 dec a[148] ;yes,decrease durati[145].
- 475 lda a[148] ;[161] durati[145] [197]ue.
- 480 bne delay ;[139] [179][177]0 [167] delay.
- 485 ;
- 490 lda #$10 ;si[195]ce sound by set[171]
- 495 sta vcreg1 ;ting bit 0 off.
- 500 rts ;[142] [164] caller.
- 505 ;
- 510 [128] lda #$00;zero all registers.
- 515 sta vcreg1 ;[151] 54276,0
- 520 sta atdcy1 ;[151] 54277,0
- 525 sta surel1 ;[151] 54278,0
- 530 sta [184]lo1 ;[151] 54272,0
- 535 sta [184]hi1 ;[151] 54273,0
- 540 sta sigvol ;[151] 54296,0
- 545 rts ;[142] [164] caller.
- 550 ;
- 555 ; temp[176]ary s[164]rage
- 560 ;
- 565 x[148] .byte $00
- 570 a[148] .byte $00
- 575 ;
- 580 ; hi, lo [175] relative durati[145]
- 585 ;
- 590 [168]es [178] [172]
- 595 .byte $33,$61,$02
- 600 .byte $22,$4b,$01
- 605 .byte $26,$7e,$01
- 610 .byte $2b,$34,$01
- 615 .byte $2d,$c6,$01
- 620 .byte $33,$61,$02
- 625 .byte $22,$4b,$02
- 630 .byte $22,$4b,$02
- 635 .byte $39,$ac,$02
- 640 .byte $2d,$c6,$01
- 645 .byte $33,$61,$01
- 650 .byte $39,$ac,$01
- 655 .byte $40,$bc,$01
- 660 .byte $44,$95,$02
- 665 .byte $22,$4b,$02
- 670 .byte $22,$4b,$02
- 675 .byte $2d,$c6,$02
- 680 .byte $33,$61,$01
- 685 .byte $2d,$c6,$01
- 690 .byte $2b,$34,$01
- 695 .byte $26,$7e,$01
- 700 .byte $2b,$34,$02
- 705 .byte $2d,$c6,$01
- 710 .byte $2b,$34,$01
- 715 .byte $26,$7e,$01
- 720 .byte $22,$4b,$01
- 725 .byte $26,$7e,$02
- 730 .byte $2b,$34,$01
- 735 .byte $26,$7e,$01
- 740 .byte $22,$4b,$01
- 745 .byte $1f,$ff,$01
- 750 .byte $22,$4b,$04
-